import student from '../../api/student'

const state = {
  // 文章列表
  studentList: [],
  // 页码
  pagination: null,
};

const mutations = {
  // 设置文章列表
  SET_STUDENT_LIST(state, data) {
    state.studentList = data
  }
};

const actions = {
  /**
   * 获取文章列表
   * @param state
   * @param commit
   * @param params
   * @returns {Promise<void>}
   */
  async studentList({state, commit}, params) {
    let ret = await student.list(params);
    commit("SET_STUDENT_LIST", ret.data.data);

    return ret.data.data;
  },

  /**
   * 删除文章
   * @param state
   * @param commit
   * @param id
   * @return {Promise<void>}
   */
  async hiddenStudent({state, commit}, params) {
    return await student.delete(params);
  },

  /**
   * 更新文章
   * @param state
   * @param commit
   * @param params
   * @return {Promise<void>}
   */
  async updateStudent({state, commit}, params) {
    return await student.update(params);
  }

};

export default {
  namespaced: true,
  state,
  actions,
  mutations
}
